import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { setupStore } from './store'
import 'ant-design-vue/dist/reset.css'
import './styles/index.scss'
import './styles/theme.scss'
import { getEnv } from './utils/env'

async function bootstrap() {
  const app = createApp(App)

  // 初始化标题与 favicon（支持环境变量）
  const env = getEnv()
  if (env.APP_TITLE) {
    document.title = env.APP_TITLE
  }
  const ensureFavicon = (href) => {
    if (!href) return
    let link = document.querySelector("link[rel='icon']")
    if (!link) {
      link = document.createElement('link')
      link.setAttribute('rel', 'icon')
      document.head.appendChild(link)
    }
    link.setAttribute('href', href)
  }
  ensureFavicon(env.APP_LOGO)

  // 配置 store
  setupStore(app)

  // 配置路由
  app.use(router)

  // 挂载应用
  app.mount('#app')
}

bootstrap()
